﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace BuildRunner
{
	/// <summary>
	/// ucWorking.xaml の相互作用ロジック
	/// </summary>
	public partial class ucWorking : UserControl
	{
		public ucWorking()
		{
			InitializeComponent();
		}

		[BindableAttribute( true )]
		public eStatus Status
		{
			get { return (eStatus)GetValue( StatusProperty ); }
			set { SetValue( StatusProperty, value );
				switch( value ) {
					case eStatus.Wait:
						Busy.Visibility = System.Windows.Visibility.Collapsed;
						check.Visibility = System.Windows.Visibility.Collapsed;
						break;
					case eStatus.Busy:
						Busy.Visibility = System.Windows.Visibility.Visible;
						check.Visibility = System.Windows.Visibility.Collapsed;
						break;
					case eStatus.Comp:
						Busy.Visibility = System.Windows.Visibility.Collapsed;
						check.Visibility = System.Windows.Visibility.Visible;
						break;
				}
			}
		}

		public static readonly DependencyProperty StatusProperty =
			DependencyProperty.Register( "Status", typeof( eStatus ), typeof( ucWorking ), new UIPropertyMetadata( eStatus.Wait,  new PropertyChangedCallback( tete )  ) );

		static void tete( DependencyObject d, DependencyPropertyChangedEventArgs e )
		{
			( d as ucWorking ).Status = (eStatus)e.NewValue;

		}

		[BindableAttribute( true )]
		private double Scale
		{
			get { return (double)GetValue( ScaleProperty ); }
			set { SetValue( ScaleProperty, value ); }
		}

		public static readonly DependencyProperty ScaleProperty =
			DependencyProperty.Register( "Scale", typeof( double ), typeof( ucWorking ), new UIPropertyMetadata( 3.00 ) );

		private void UserControl_SizeChanged( object sender, SizeChangedEventArgs e )
		{
			double dbX = ActualWidth / 64;
			double dbY = ActualHeight / 64;
			if( dbX < dbY )
				Scale = dbX;
			else
				Scale = dbY;

			Scale *= 0.705;
		}

		public enum eStatus
		{
			Wait,
			Busy,
			Comp,
		}

	}
}
